package com.fenghongzhang.login;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.fenghongzhang.lib.mvp.view.BaseActivity;
import com.fenghongzhang.login.entity.LoginInfo;
import com.fenghongzhang.login.mvp.contract.LoginContract;
import com.fenghongzhang.login.mvp.model.LoginModel;
import com.fenghongzhang.login.mvp.presenter.LoginPresenter;

public class MainActivity extends BaseActivity<LoginPresenter> implements LoginContract.ILoginView {

    private EditText name;
    private EditText pwd;
    private Button login;
    @Override
    public int bindLayout() {
        return R.layout.activity_main;
    }

    @Override
    public void initView() {
        name = (EditText) findViewById(R.id.name);
        pwd = (EditText) findViewById(R.id.pwd);
        login = (Button) findViewById(R.id.login);
    }

    @Override
    public void initData() {
        mPresenter = new LoginPresenter(new LoginModel(),this);

    }



    @Override
    public String getName() {
        return name.getText().toString();
    }

    @Override
    public String getPwd() {
        return pwd.getText().toString();
    }

    @Override
    public void isLoginOk(LoginInfo info) {
        Toast.makeText(this, info.getMessage(), Toast.LENGTH_SHORT).show();
    }

    @Override
    public void showMsg(String s) {

    }

    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }

    public void login(View view) {
        mPresenter.login();
//        mPresenter.login();
    }
}
